﻿using System;
using System.Collections.Generic;
using System.Text;

namespace BLL
{
    public class LabEquipment
    {
        /// <summary>
		/// 增加一条数据
		/// </summary>
        public static int Add(Model.LabEquipment model)
        {
            return DAL.LabEquipmentService.Add(model);
        }
        //根据分类列出属性
        public static List<Model.Parameter> GetParamList(int s)
        {
            return DAL.ParameterService.GetParamList(s.ToString());
        }
        //根据条件列出实验室
        public static List<Model.Lab> GetLabList(string strWhere = "")
        {
            return DAL.LabService.GetLabList(strWhere);
        }
        //根据条件列出设备
        public static List<Model.LabEquipment> GetLabEquipmentList(string strWhere = "")
        {
            return DAL.LabEquipmentService.GetLabEquipmentList(strWhere);
        }
        //根据ID查询一条设备
        public static Model.LabEquipment SelectLabEquipmentByID(int id)
        {
            return DAL.LabEquipmentService.SelectLabEquipmentByID(id);
        }
        //根据pNO查询一条设备
        public static Model.LabEquipment SelectLabEquipmentBypNO(string pNO)
        {
            return DAL.LabEquipmentService.SelectLabEquipmentBypNO(pNO);
        }
        //根据ID更新一条设备
        public static bool Update(Model.LabEquipment m)
        {
            return DAL.LabEquipmentService.Update(m);
        }
        //根据ID删除一条设备
        public static bool DelLabEquipmentByID(int id)
        {
            return DAL.LabEquipmentService.DelLabEquipmentByID(id);
        }
        //设备待处理
        public static bool WaitLabEquipmentByID(int id)
        {
            return DAL.LabEquipmentService.ChangeStatusByID(id,"wait");
        }
        //设备在用
        public static bool UsingLabEquipmentByID(int id)
        {
            return DAL.LabEquipmentService.ChangeStatusByID(id,"using");
        }
        //设备报废
        public static bool EquipmentAbandon(Model.EquipmentAbandon model)
        {
            if (DAL.LabEquipmentService.EquipmentAbandon(model) && DAL.LabEquipmentService.ChangeStatusByID(model.EID, "aban"))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        //设备借出
        public static bool EquipmentRent(Model.EquipmentRent model)
        {
            if (DAL.LabEquipmentService.EquipmentRent(model) != 0 && DAL.LabEquipmentService.ChangeStatusByID(model.EID, "rent"))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        //设备归还
        public static bool EquipmentReturn(Model.EquipmentRent model,string status)
        {
            if(DAL.LabEquipmentService.EquipmentReturn(model) && DAL.LabEquipmentService.ChangeStatusByID(model.EID,status))
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        //设备报修
        public static bool EquipmentRepair(Model.EquipmentRepair model)
        {
            if (DAL.LabEquipmentService.EquipmentRepair(model) != 0 && DAL.LabEquipmentService.ChangeStatusByID(model.EID, "fix"))
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        //设备维修反馈
        public static bool EquipmentFixok(Model.EquipmentRepair model, string status)
        {
            if(DAL.LabEquipmentService.EquipmentFixok(model) && DAL.LabEquipmentService.ChangeStatusByID(model.EID,status))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
